package connectfour;

import java.util.Random;

public class Risk {
	
	
	
private static int checkOrizzontalRisk(int curr_col, int curr_row, Grid grid, int counter) {
		
		while (counter<3){
			if (curr_col+1>6) curr_col=5;
			if (grid.getContent(curr_col+1, curr_row) == 1){ 
				counter++;
				curr_col=curr_col+1;
				Opponent.checkOrizzontalRisk(curr_col,curr_row,grid,counter);
			} 
			else break;
		}
	}	
	
	private void reactOrizzontalRisk(int curr_col,int curr_row)
		if (grid.isUnfilled(curr_row, curr_col+1)) grid.setYellow(curr_row, curr_col);
		else Opponent.noRisk();
			
	
	
	
	
	
	
	
	
	
	
			else if (grid.getContent(curr_col, curr_row+1) == 1){
				counter++;
				curr_row=curr_row+1;
				Opponent.checkOthers(curr_col,curr_row,grid,counter);
			}
			else if (grid.getContent(curr_col+1, curr_row+1) == 1){
				counter++;
				curr_col=curr_col+1;
				curr_row=curr_row+1;
				Opponent.checkOthers(curr_col,curr_row,grid,counter);
			}
		}
		
		
	}
		return false;
	}
	



if (curr_row+1>5) curr_col=4;




	public static void noRisk(){
		Random random = new Random();
		int col = random.nextInt(6);
		int row = 0;
		boolean done = false;
		while (done){
			if (grid.isUnfilled(row, col)){
				grid.setYellow(row, col);
				done = true;
			} 
			row++;
		}
	}
	
	
	
	
	
	

}
